<template>
	<uni-popup ref="agreement" type="center" :is-mask-click='false'>
		<view class="agreement">
			<view class="title">隐私政策</view>
			<view class="c-content" v-html='html'></view>
			<view class="bottom">
				<view class="b-top">
					请点击同意按钮，代表您已阅读并同意了小黄人的<text @click="$util.redirectTo('/pages/agreement/agreement',{title:'隐私政策',type:'Policy'})">
						《隐私政策》</text>及
					<text @click=" $util.redirectTo('/pages/agreement/agreement',{title:'用户协议',type:'Myxy'})">《用户协议》</text>
				</view>
				<view class="box-but">
					<view class="item" :class="{'item-hover':index != 0 }" v-for="(item,index) in list" :key="index" @click="deletes(index)">{{item}}</view>
				</view>
			</view>

		</view>
	</uni-popup>
</template>

<script>
	export default {
		data(){
			return {
				list:['不同意','同意'],
				html:''
			}
		},
		methods:{
			open(){
				this.$http.sendrequest('/index/Policy').then(res=>{
					this.html = res.data.value
					this.$refs.agreement.open();
				})
				
			},
			deletes(index){
				switch(index){
					case 0:
						if (plus.os.name.toLowerCase() === 'android') {
							 plus.runtime.quit();
						} else { 
							 const threadClass = plus.ios.importClass("NSThread");
							 const mainThread = plus.ios.invoke(threadClass, "mainThread");
							 plus.ios.invoke(mainThread, "exit");
						 }
						break;
					case 1:
						uni.setStorageSync('is_agreement',true)
						this.$refs.agreement.close();
						break;
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.agreement{
		width: 74vw;
		height: 60vh;
		background: #fff;
		border-radius: 10rpx;
		overflow: hidden;
		position: relative;
		.title{
			height: 80rpx;
			background-image: linear-gradient(#ff6f30, rgba(255,111,48,.8));
			font-size: 30rpx;
			color: #fff;
			text-align: center;
			line-height: 80rpx;
		}
		.c-content{
			height: calc(100% - 250rpx);
			padding: 30rpx 30rpx 0;
			box-sizing: border-box;
			overflow-y:scroll;
		}
		.bottom{
			height: 160rpx;
			position: absolute;
			bottom: 0;
			left: 0;
			width:100%;
			.b-top{
				text-align: center;
				height: 80rpx;
				font-size: 24rpx;
				line-height: 1.4;
				padding: 0 30rpx;
				box-sizing: border-box;
				color: #7b7a7a;
				text{
					color: #ff6f30;
				}
			}
			.box-but{
				display: flex;
				align-items: center;
				justify-content: space-between;
				width: 100%;
				height: 80rpx;
				.item{
					flex: 1;
					background: #d7d3d2;
					font-size: 28rpx;
					text-align: center;
					line-height: 80rpx;
					height: 80rpx;
				}
				.item-hover{
					color: #fff;
					background-image: linear-gradient(#ff6f30, rgba(255,111,48,.8));
				}
			}
		}
		
	}
</style>